package bszt.ant;

import java.util.Scanner;

class Point {
    int x, y;

    Point(int x, int y) {
        this.x = x;
        this.y = y;
    }
}

public class Code02 {

    /**
     * 问题描述
     * LYA在平面上找到了四个点的坐标，想要判断这四个点能否构成一个等腰梯形。等腰梯形的定义为：四条边分为两对，有一对边平行且不相等，另一对边相等且不平行
     * 给定四个点的坐标，请帮助LYA判断它们是否能构成一个等腰梯形
     * <p></p>
     * 输入格式
     * 第一行包含一个正整数q，表示询问的次数。
     * 接下来的q行，每行包含8个整数，分别表示四个点的坐标
     * <p></p>
     * 输出格式
     * 对于每个询问，如果给定的四个点能构成等腰梯形，则输出 "Yes"，否则输出 "No"
     */


    public static double dist(Point a, Point b) {
        return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
    }

    public static boolean isParallel(Point a, Point b, Point c, Point d) {
        return (b.y - a.y) * (d.x - c.x) == (d.y - c.y) * (b.x - a.x);
    }

    public static boolean isIsosceles(Point a, Point b, Point c, Point d) {
        double d12 = dist(a, b), d23 = dist(b, c), d34 = dist(c, d), d41 = dist(d, a);
        double d13 = dist(a, c), d24 = dist(b, d);

        if (isParallel(a, b, c, d) && d12 != d34) {
            return (d13 == d24) || (d41 == d23);
        }
        if (isParallel(a, c, b, d) && d13 != d24) {
            return (d12 == d34) || (d41 == d23);
        }
        if (isParallel(a, d, b, c) && d41 != d23) {
            return (d12 == d34) || (d13 == d24);
        }
        return false;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        while (q-- > 0) {
            Point a = new Point(sc.nextInt(), sc.nextInt());
            Point b = new Point(sc.nextInt(), sc.nextInt());
            Point c = new Point(sc.nextInt(), sc.nextInt());
            Point d = new Point(sc.nextInt(), sc.nextInt());
            System.out.println(isIsosceles(a, b, c, d) ? "Yes" : "No");
        }
    }
}
